package com.lgd.warehousemanagement.httpService;

import com.lgd.warehousemanagement.Bean.FactoryDeviceManagement;
import com.lgd.warehousemanagement.Bean.ProjectType;
import com.lgd.warehousemanagement.Bean.SysUser;
import com.lgd.warehousemanagement.Bean.WorkHourCache;
import com.lgd.warehousemanagement.Bean.WorkHourStatistics;
import com.lgd.warehousemanagement.httpService.httpPort.IHttpHelper;
import com.lgd.warehousemanagement.httpService.httpPort.IResponse;
import com.lgd.warehousemanagement.httpService.httpPort.IStringResponse;

/**
 * @Author lgd
 * @Date 2024/1/18 13:42
 */
public class API {
    private static final String TAG = "API";
    private  static IHttpHelper httpHelper;
    // 本机 地址
//    private  static String serverUrl = "http://192.168.3.9:8080";
    // 网络地址
    private  static String serverUrl = "http://111.229.152.119:8080";
    /**
     * API组件初始化，不可static直接赋值，防止GlobalInfo未初始化造成null
     */
    public static void init(){
        IHttpHelper iHttpHelper = new HttpHelperImpl();
        httpHelper = iHttpHelper;
        System.out.println("http初始化成功");
    }
    //  根据 卡片序列号/员工姓名 查询用户信息
    public static void seleceStaffInfo(SysUser sysUser, IStringResponse response){
        httpHelper.post(serverUrl+"/system/user/seleceStaffInfo",sysUser,response);
    }
    //  获取项目 分类类型
    public static void projectType(IResponse response){
        httpHelper.get(serverUrl+"/projectManagement/projectManagement/getStartProjectClassification",response);
    }
    //  获取项目 列表信息
    public static void getStartProjectInfo(ProjectType projectType, IStringResponse response){
        httpHelper.post(serverUrl+"/projectManagement/projectManagement/getStartProjectInfo",projectType,response);
    }
    // 获取 领料状态
    public static void selectCacheStatus(WorkHourCache workHourCache, IStringResponse response){
        httpHelper.post(serverUrl+"/workHourCache/workHourCache/selectCacheStatus",workHourCache,response);
    }
    //  添加 领料工单
    public static void addWorkHourCache(WorkHourCache workHourCache, IStringResponse response){
        httpHelper.post(serverUrl+"/workHourCache/workHourCache/addWorkHourCache",workHourCache,response);
    }
    //  开始+ 结束 +userID 计算工时
    public static void calculateDuration(WorkHourStatistics workHourStatistics, IStringResponse response){
        httpHelper.post(serverUrl+"/workHourStatistics/workHourStatistics/calculateDuration",workHourStatistics,response);
    }
    // 缓存表更新
    public static void updateCache(WorkHourCache workHourCache, IStringResponse response){
        httpHelper.post(serverUrl+"/workHourCache/workHourCache/updateCache",workHourCache,response);
    }
    // 添加设备 信息
    public static void addSerialNumber(FactoryDeviceManagement factoryDeviceManagement, IStringResponse response){
        httpHelper.post(serverUrl+"/deviceManagement/deviceManagement/addSerialNumber",factoryDeviceManagement,response);
    }
    // 查询 领料异常工单
    public static void selectAbnormalOrder(WorkHourCache workHourCache,IStringResponse response){
        httpHelper.post(serverUrl+"/workHourCache/workHourCache/selectAbnormalOrder",workHourCache,response);
    }
    //  修改 缓存表
    public static void updateWorkCache(WorkHourCache workHourCache, IStringResponse response){
        httpHelper.post(serverUrl+"/workHourCache/workHourCache/updateWorkCache",workHourCache,response);
    }
}
